package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.StarPaintRegisterDO;
import com.starlink.model.request.StarPaintRegisterRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface StarPaintRegisterMapper extends BaseMapper<StarPaintRegisterDO> {
    StarPaintRegisterDO selectDOById(Long id);
    List<StarPaintRegisterDO> selectDOList(StarPaintRegisterDO starPaintRegister);
    int insertDO(StarPaintRegisterDO starPaintRegister);
    int batchInsertDO(List<StarPaintRegisterDO> starPaintRegisterDOList);
    int updateDO(StarPaintRegisterDO starPaintRegister);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from star_paint_register",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") StarPaintRegisterRequest param);
    @Select({"<script>",
            "   select * from star_paint_register",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<StarPaintRegisterDO> pageQuery(@Param("param") StarPaintRegisterRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<StarPaintRegisterDO> listQuery(StarPaintRegisterRequest request);
}
